import {
  societyDetails
} from '../../apis/index';
import {
  splicing
} from '../../utils/util';
import {
  request
} from "../../utils/request";
const app = getApp();

Page({
  data: {
    societyDetails: {},
    domain: request.defaults.editorURL
  },

  onLoad(options) {
    this.setData({
      ...options
    });
    this.getSocietyDetails(options.societyId);
  },

  onShareAppMessage() {
    return {
      title: this.data.societyDetails.title,
      path: `/pages/aboutSociety/index?societyId=${this.data.societyId}`,
      imageUrl: this.data.societyDetails.image
    }
  },

  getSocietyDetails(id) {
    wx.showLoading({
      title: '加载中...',
      mask: true
    });
    societyDetails(id).then(res => {
      wx.hideLoading();
      if (res.data.code === 200) {
        let {
          data
        } = res.data;
        wx.setNavigationBarTitle({
          title: data.title
        });
        data.image = splicing(data.image);
        this.setData({
          societyDetails: data
        });
      };
    });
  }
})